let priceModel = require("../models/pigPrice").priceList;

let pigPriceDAO = function (){};

pigPriceDAO.prototype = {
  //增
  save: function (json, callBack){
    let newPrice = new priceModel(json);
    newPrice.save(function (err){
      callBack(err);
    });
  },
  // //删
  remove: function (json, callBack){
    priceModel.remove(json, function (err){
      callBack(err);
    });
  },
  // //改
  update: function (json, condition, callBack){
    priceModel.update(json, condition, function (err){
      callBack(err);
    });
  },
  //查询列表
  findAll: function (callBack){
    priceModel.find(function (err, doc){
      callBack(err, doc);
    });
  },
  //查询单个
  findOneById: function (id, callBack){
    priceModel.findOne({_id: id}, function (err, doc){
      callBack(err, doc);
    });
  }
};

exports.priceMethod = new pigPriceDAO();
